<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>
    <button id="getInfo">Get Info</button>
    <script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <script>
        function getInfo() {
            $.ajax({
                url:"/user/info",
                contentType:"application/json",
                dataType:"json",
                beforeSend:function (request) {
                    request.setRequestHeader("Authorization",localStorage.getItem("token"));
                },
                success:function (result) {
                    if(result.code == 200){
                        alert(JSON.stringify(result));
                    }else {
                        alert(result.msg);
                    }
                }
            });
        }

        $("#getInfo").click(function () {
            getInfo();
        });

        $(function () {
            getInfo();
        });
    </script>
</body>
</html>